from rest_framework import serializers

from apps.list.models import ListInfo


class ListInfoSerializer(serializers.ModelSerializer):
    class Meta:
        model = ListInfo
        fields = '__all__' # 默认生成所有字段

    def validate(self,attrs):
        print(attrs['age'])
        print(attrs['sex'])
        return attrs

    def create(self, validated_data):
        print(validated_data)
        info = ListInfo.objects.create(**validated_data)
        return info


